function debounce(fn, delaySeconds) {
    let timer = ''
    const capitalize = str => str ? str[0].toUpperCase() + str.slice(1) : str
    // 动态设置函数名
    const res = {
        ['deb' + (fn.name ? capitalize(fn.name) : 'Fn')](...args) {
            timer && clearTimeout(timer)
            timer = setTimeout(() => {
                fn.apply(this, args)
            }, delaySeconds * 1000)
        }
    }

    return Object.values(res).pop()

}


function hello(name) {
    console.log('hello', name)
}


const debHello = debounce(hello, 2);

// 模拟高频执行
function highFrequencyCall(fn, args = [], msDelay = 300, maxTimes = 10) {
    let callTimes = 0
    let timer = null
    timer = setInterval(() => {
        if (callTimes >= maxTimes) {
            clearInterval(timer)
            return
        }

        callTimes++;
        console.log(callTimes, 'calling fn:', fn.name)
        fn.apply(this, args)
    }, msDelay)
}

highFrequencyCall(debHello, ['Alice'])